package com.wufeng.config;

import com.wufeng.intercepter.JwtIntercepter;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 为上传的文件添加一个资源处理器,用来动态刷新静态资源，确保资源能够被正确访问
        registry.addResourceHandler("/imgs/avatar/**")
                .addResourceLocations("file:src/main/resources/static/imgs/avatar/");
    }

    /**
     * 添加拦截器
     *
     * @param registry
     */
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // 注册JWT拦截器
//        registry.addInterceptor(new JwtIntercepter())
//                .excludePathPatterns("/user/login", "/user/register")
//                .addPathPatterns("/**");
//    }
}
